#函数的多返回值，可以返回多个值，只要用多个变量来接收就行
def my_func():
    return 1,2,"feng"

# print(f"{my_func()}")
x, y, z = my_func()
print(f"{x} {y} {z}")

#多种传参方式
def my_function(name, age, gender):
    print(f"name is {name}, age is{age}, gender is {gender}")

my_function(name="zhangsan", gender = "man", age=18)#---------顺序可以不对应
my_function("feng", 19, "women")

#位置不定长传递*args, 参数会自动转化为元组， 传入长度不受限制
def my_func(*args):
    print(f"传入的参数是：{args}, 类型是:{type(args)}")

my_func(1,2,3,"fengjsiod")

#关键字不定长，**kwargs，调用时必须传入键值对形式的参数，传入的长度不受限制, 参数会自动转化为字典
def my_func(**kwargs):
    print(f"传入的参数是：{kwargs}, 类型是:{type(kwargs)}")

my_func(name = "小冯", age = 19, gender = "男", address = "巴中")

# def exchage(x, y):
#     tmp = x
#     x = y
#     y = tmp

# x = 10
# y = 20
# print(f"{x} {y}")
# exchage(x, y)
# print(f"{x} {y}")

def test_fun(compute):
    result = compute(1,2)
    print(result)
    print(type(compute))

def compute(x, y):
    return x + y

test_fun(compute)
#---------直接调用函数和函数作为参数调用似乎没啥区别
def test_fun():
    result = compute(1,2)
    print(result)

def compute(x, y):
    return x + y

test_fun()


#lambda函数--------没有函数名称，只能使用一次的函数, lambda函数只能写一行
def test_fun(compute):
    result = compute(1,2)
    print(result)
    print(type(compute))

# def compute(x, y):
#     return x + y

test_fun(lambda x, y : x + y)